#include "DirectShowDemo.h"
#include <QtWidgets/QApplication>
#include <QDebug>
static void load_debug_privilege(void)
{
	const DWORD flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY;
	TOKEN_PRIVILEGES tp;
	HANDLE token;
	LUID val;

	if (!OpenProcessToken(GetCurrentProcess(), flags, &token)) {
		return;
	}

	if (!!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &val)) {
		tp.PrivilegeCount = 1;
		tp.Privileges[0].Luid = val;
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

		AdjustTokenPrivileges(token, false, &tp, sizeof(tp), NULL,
			NULL);
	}

	if (!!LookupPrivilegeValue(NULL, SE_INC_BASE_PRIORITY_NAME, &val)) {
		tp.PrivilegeCount = 1;
		tp.Privileges[0].Luid = val;
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

		if (!AdjustTokenPrivileges(token, false, &tp, sizeof(tp), NULL,
			NULL)) {
			//blog(LOG_INFO, "Could not set privilege to "
			//	"increase GPU priority");
			qDebug() << "Could not set privilege to increase GPU priority";
		}
	}

	CloseHandle(token);
}

int main(int argc, char *argv[])
{
	load_debug_privilege();

    QApplication a(argc, argv);
    DirectShowDemo w;
    w.show();
    return a.exec();
}
